/**
 * Title: RoleController.java
 * @author wujin
 * @date 2019年12月30日
 * @version 1.0
 */
package com.pm.controller.task;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.pm.common.Pages;
import com.pm.common.Response;
import com.pm.common.annotation.MyLog;
import com.pm.common.annotation.UserLoginToken;
import com.pm.common.exception.ExpCodeState;
import com.pm.entity.po.task.SubtaskQuarterDegree;
import com.pm.service.task.SubtaskQuarterDegreeService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;

/**
 * Title: RoleController
 * 
 * @author wujin
 * @date 2019年12月30日
 */
@Api(tags = "指标进度")
@ApiModel
@UserLoginToken
@RestController
@RequestMapping("/subtaskDegree")
public class SubtaskCompletDegreeController {
	@Autowired
	private SubtaskQuarterDegreeService subtaskQuarterDegreeService;

	@ApiOperation("单个对象查询接口")
	@PostMapping("/load")
	@ResponseBody
	public Response<SubtaskQuarterDegree> load(SubtaskQuarterDegree subtaskQuarterDegree) {
		Response<SubtaskQuarterDegree> response = null;
		SubtaskQuarterDegree result = subtaskQuarterDegreeService.load(subtaskQuarterDegree);
		response = new Response<SubtaskQuarterDegree>(ExpCodeState.query_data_success, result);
		return response;
	}

	@ApiOperation("全部列表查询接口")
	@PostMapping("/getList")
	@ResponseBody
	@MyLog(value = "查询指标完成度列表")
	public Response<List<SubtaskQuarterDegree>> getList(SubtaskQuarterDegree subtaskQuarterDegree) {
		List<SubtaskQuarterDegree> result = subtaskQuarterDegreeService.getList(subtaskQuarterDegree);
		Response<List<SubtaskQuarterDegree>> res = new Response<List<SubtaskQuarterDegree>>(
				ExpCodeState.query_data_success, result);
		return res;
	}

	@ApiOperation("分页查询接口")
	@PostMapping("/getListByPage/{pageNum}/{pageSize}")
	@ResponseBody
	@MyLog(value = "查询指标完成度列表")
	public Response<PageInfo<SubtaskQuarterDegree>> getList(SubtaskQuarterDegree subtaskQuarterDegree, Pages page) {
		PageInfo<SubtaskQuarterDegree> result = subtaskQuarterDegreeService.getListByPage(subtaskQuarterDegree, page);
		Response<PageInfo<SubtaskQuarterDegree>> res = new Response<PageInfo<SubtaskQuarterDegree>>(
				ExpCodeState.query_data_success, result);
		return res;
	}

	@ApiOperation("更新接口")
	@PostMapping("/update")
	@ResponseBody
	@MyLog(value = "编辑指标完成度信息")
	public Response<Integer> update(@RequestBody SubtaskQuarterDegree subtaskQuarterDegree) {
		Integer result = subtaskQuarterDegreeService.update(subtaskQuarterDegree);
		Response<Integer> response = null;
		if (result > 0) {
			response = new Response<>(ExpCodeState.update_data_success, result);
		} else {
			response = new Response<>(ExpCodeState.update_data_failed);
		}
		return response;
	}

	@ApiOperation("新增接口")
	@PostMapping("/add")
	@ResponseBody
	@MyLog(value = "新增指标完成度信息")
	public Response<Integer> add(@RequestBody SubtaskQuarterDegree subtaskQuarterDegree) {
		Integer result = subtaskQuarterDegreeService.add(subtaskQuarterDegree);
		Response<Integer> response = null;
		if (result > 0) {
			response = new Response<>(ExpCodeState.add_data_success, result);
		} else {
			response = new Response<>(ExpCodeState.add_data_failed);
		}
		return response;
	}
	
	@ApiOperation("删除接口")
	@PostMapping("/remove")
	@ResponseBody
	@MyLog(value = "删除指标完成度信息")
	public Response<Integer> remove(@RequestBody SubtaskQuarterDegree subtaskQuarterDegree) {
		Response<Integer> response = null;
		Integer result = subtaskQuarterDegreeService.remove(subtaskQuarterDegree);
		if (result > 0) {
			response = new Response<>(ExpCodeState.remove_data_success, result);
		} else {
			response = new Response<>(ExpCodeState.remove_data_failed);
		}
		return response;
	}
}
